
package com.xtsoft.platform.base.system.service.impl;


import com.xtsoft.core.service.impl.GenericServiceImpl;
import com.xtsoft.core.utils.tree.TreeBuilder;
import com.xtsoft.platform.base.system.domain.SysRegion;
import com.xtsoft.platform.base.system.repository.SysRegionRepository;
import com.xtsoft.platform.base.system.service.SysRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("sysRegionService")
public class SysRegionServiceImpl extends GenericServiceImpl<SysRegion,String, SysRegionRepository> implements SysRegionService {

	@Autowired
	public SysRegionRepository sysRegionRepository;
	
	/**
	 * 构建机构树
	 */
	@Override
	public String getRegionTree(String currentuserId) {
		String result = "";
		Sort sort = Sort.by(Sort.Direction.ASC, "regionId");   
		List<SysRegion> list= sysRegionRepository.findAll(sort);
		String TreeResource[] = {"regionId","preRegionId","regionName","regUniqueId"};
		TreeBuilder<SysRegion> treeBuilder = new TreeBuilder<SysRegion>();
		//result = treeBuilder..build(list,TreeResource, SysRegion.class);
		return result;
	}
	
	
	public SysRegion findByRegionId(String regionId){
		return sysRegionRepository.findByRegionId(regionId);
	}

	@Override
	public List<SysRegion> findByPreRegionId(String preRegionId) {
		return sysRegionRepository.findByPreRegionId(preRegionId);
	};

}